<?php
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/user/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/tucao/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/mblog/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/album/inc.php");


//所有的参数
$g_cgival 	= array();
//存储中间数据 非输出数据 可以不用
$g_pro	 	= array();
//要显示的数据 输出数据
$g_show 	= array();

function check_cgi_pro()
{		
	global $g_cgival, $g_pro, $g_show, $config;
	
	cgi::both($g_cgival["p"], "p", "");
	$g_cgival["p"] = intval($g_cgival["p"]);
	
	if($g_cgival["p"] < 1) $g_cgival["p"]=1;
	
	cgi::both($g_cgival["topic_id"], "topic_id", "");
	$g_cgival["topic_id"] = intval($g_cgival["topic_id"]);
	
	cgi::both($g_cgival["show_type"], "show_type", "");
	$g_cgival["show_type"] = intval($g_cgival["show_type"]);
	
	cgi::both($g_cgival["order"], "order", "hot");
	
	cgi::both($g_cgival["uid"], "uid", "");
	$g_cgival["uid"] = intval($g_cgival["uid"]);
}


function get_data()
{
	global $g_cgival, $g_pro, $g_show, $config;
	
	
	$db_mblog_cron_topic_tag = new db_mblog_cron_topic_tag();
	$list1 = $db_mblog_cron_topic_tag->get_mblog_cron_topic_tag_list_order_by_like(1,1,10);
	foreach($list1 as $key => $value)
	{
		$list1[$key]["change"] = $value["count_mblog_newly"] - $value["count_mblog_last_newly"]  ;
	}
		
	$list2 = $db_mblog_cron_topic_tag->get_mblog_cron_topic_tag_list_order_by_like(2,1,10);
	
	foreach($list2 as $key => $value)
	{
		$list2[$key]["change"] = $value["count_mblog_newly"] - $value["count_mblog_last_newly"]  ;
	}
		
	
	$list3 = $db_mblog_cron_topic_tag->get_mblog_cron_topic_tag_list_order_by_like(3,1,10);
	foreach($list3 as $key => $value)
	{
		$list3[$key]["change"] = $value["count_mblog_newly"] - $value["count_mblog_last_newly"]  ;
	}
		
	$g_show["list1"] = $list1;
	$g_show["list2"] = $list2;
	$g_show["list3"] = $list3;
	$page_title = "游戏热度变化榜-每天更新";
	$g_show["page_title"] =$page_title;
	
	
	
}

try {
	$g_show['error'] = 0;
	$g_show['errmsg'] = "";
	check_cgi_pro();
	get_data();
	
} catch (Exception $e) {
	$g_show['error'] = 1;
	$g_show['errmsg'] = $e->getMessage();
}

show_pro();


exit;

function show_pro()
{
	global $g_cgival, $g_pro, $g_show, $config;

	$smarty = p_get_smarty();	
	$smarty->assign("g_show", $g_show);
	if (isset($_GET["debug"]))
	{
		print_r($g_show);
	}
	$smarty->display("top/index.html");
	
	unset($g_cgival);
	unset($g_pro);
	unset($g_show);
	unset($config);
	
}

